package day11.problem2;

//倒置字符串
//https://www.nowcoder.com/practice/ee5de2e7c45a46a090c1ced2fdc62355?tpId=182&tqId=34788&ru=/exam/oj

import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        char[] s = in.nextLine().toCharArray();
        int n = s.length;
        reverse(s, 0, n-1);
        int i = 0;
        while(i < n) {
            int j = i;
            while(j < n && s[j] != ' ') {
                j++;
            }
            reverse(s, i, j-1); 
            i = j+1;
        }
        System.out.println(new String(s));
    }

    public static void reverse(char[] s, int l, int r) {
        while(l < r) {
            char t =s[l];
            s[l] = s[r];
            s[r] = t;
            l++;
            r--;
        }
    }
}